package lunsfordhall.androidapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


public class Form2 extends Activity{
	public void onCreate(Bundle savedInstanceState) {// bundles all of work and saves
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.form2);
        
        
        final EditText edittext = (EditText) findViewById(R.id.edittext);// enter text box for distance
        final EditText edittext2 = (EditText) findViewById(R.id.edittext2);// enter text box for velocity intital
        final EditText edittext3 = (EditText) findViewById(R.id.edittext3);// enter 
        final Button button = (Button) findViewById(R.id.button1);//makes button
        
        button.setOnClickListener(new OnClickListener() {//reads button action
        	public void onClick(View v) {// when click happens this ensues
        		
        		 TextView t = (TextView)findViewById(R.id.textview);// the variable for the output of answer
        		
        		double F = Double.parseDouble(edittext.getText().toString());//parsing the double variables
             	
             	double m = Double.parseDouble(edittext2.getText().toString());//parsing the double variables
             	
             	double a = Double.parseDouble(edittext3.getText().toString());//parsing the double variables
             	
             		double Force = 0;
             	    double mass = 0;
             	    double acceleration = 0;
             	    
             if(m>0 && a>0 && F==0){
            	Force = m*a;
            t.setText(String.valueOf(Force));
             }else if(F>0 && a>0 && m==0){
            mass = F/a;
            t.setText(String.valueOf(mass));
             }else if(F>0 && m>0 && a==0){
            acceleration = F/m;	
            t.setText(String.valueOf(acceleration));
            }else{ }
             
        	}
        });
	}
}
	